/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mxgraph.examples.swing;

import com.mysql.jdbc.Connection;
import java.sql.DriverManager;

/**
 *
 * @author Somesh Soni
 */
public class DevicePropertiesFrame extends javax.swing.JFrame {

    private Connection connect = null;
    String DeviceName;
    String DeviceUID;
    String contactEmailID;
    String sysAdmin;
    String alarmEmail;
    String IPs;
    String snmpPublicString;
    String snmpPrivateString;
    int deleteStatusIcon;
    int modificationFlag = 0;

    /**
     * Creates new form DeviceProperties
     */
    public DevicePropertiesFrame(String DeviceID, String Name, String contactID, String sysAdm, String alarmemail, String IP, String snmpPublic, String snmpPrivate) {
        
        
        DeviceName = Name;
        DeviceUID = DeviceID;
        IPs = IP;
        alarmEmail = alarmemail;
        sysAdmin = sysAdm;
        contactEmailID = contactID;
        //deleteStatusIcon = deleteStatus;
        snmpPublicString = snmpPublic;
        snmpPrivateString = snmpPrivate;
        if(DeviceName.isEmpty())
        {
            modificationFlag = -1;
            DeviceName = "device1.rack.location.organization";
            alarmEmail = "alarm@organization";
            contactEmailID = "sysadmin@organization";
            sysAdmin = "Name";
        }
        //initComponents();
        setVisible(true);
        initComponents();
        //       JOptionPane.showInputDialnog(this);
        //initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PFNMSLabel = new javax.swing.JLabel();
        PFNMSLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jTextFieldName = new javax.swing.JTextField();
        PFNMSLabel2 = new javax.swing.JLabel();
        jTextFieldContDetail = new javax.swing.JTextField();
        PFNMSLabel3 = new javax.swing.JLabel();
        jTextFieldSysAdmin = new javax.swing.JTextField();
        PFNMSLabel4 = new javax.swing.JLabel();
        jTextFieldAlarmEmail = new javax.swing.JTextField();
        CancelButton = new javax.swing.JButton();
        ProceedButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setAlwaysOnTop(true);
        setResizable(false);

        PFNMSLabel.setBackground(new java.awt.Color(102, 102, 102));
        PFNMSLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        PFNMSLabel.setText("Submit The Details Of The Device");

        PFNMSLabel1.setBackground(new java.awt.Color(102, 102, 102));
        PFNMSLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        PFNMSLabel1.setText("Unique Name of the Device Name");

        jTextFieldName.setText(DeviceName);

        PFNMSLabel2.setBackground(new java.awt.Color(102, 102, 102));
        PFNMSLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        PFNMSLabel2.setText("Contact Details (email ID)");

        jTextFieldContDetail.setText(contactEmailID);

        PFNMSLabel3.setBackground(new java.awt.Color(102, 102, 102));
        PFNMSLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        PFNMSLabel3.setText("System Administrator");

        jTextFieldSysAdmin.setText(sysAdmin);

        PFNMSLabel4.setBackground(new java.awt.Color(102, 102, 102));
        PFNMSLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        PFNMSLabel4.setText("Alarm email address");

        jTextFieldAlarmEmail.setText(alarmEmail);

        CancelButton.setText("Cancel");
        CancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelButtonActionPerformed(evt);
            }
        });

        ProceedButton.setText("Proceed");
        ProceedButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ProceedButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 619, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(ProceedButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(CancelButton))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(67, 67, 67)
                                    .addComponent(PFNMSLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 476, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(PFNMSLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 599, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(PFNMSLabel2))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jTextFieldContDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(PFNMSLabel3))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jTextFieldSysAdmin, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(PFNMSLabel4))
                                .addGroup(layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jTextFieldAlarmEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PFNMSLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PFNMSLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PFNMSLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldContDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PFNMSLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldSysAdmin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PFNMSLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldAlarmEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CancelButton)
                    .addComponent(ProceedButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelButtonActionPerformed
        // TODO add your handling code here:
        String cmd = evt.getActionCommand();
        if (cmd.equals("Cancel")) {
            dispose();
        }

    }//GEN-LAST:event_CancelButtonActionPerformed

    private void ProceedButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ProceedButtonActionPerformed
        // TODO add your handling code here:        
       // if(modificationFlag==-1){
        alarmEmail = jTextFieldAlarmEmail.getText();
        contactEmailID = jTextFieldContDetail.getText();
        DeviceName = jTextFieldName.getText();
        sysAdmin =jTextFieldSysAdmin.getText();
       // }
           // alarmEmail = jTextFieldAlarmEmail
    //private javax.swing.JTextField jTextFieldContDetail;
    //private javax.swing.JTextField jTextFieldName;
    //private javax.swing.JTextField jTextFieldSysAdmin;
    // End of variables declaration
            //connect = DriverManager.getConnection("jdbc:mysql://localhost/nms", "root","");
       
            dispose();
            new IPFrame(DeviceUID,  DeviceName,contactEmailID, sysAdmin, alarmEmail, IPs, snmpPublicString,  snmpPrivateString);
       
    }//GEN-LAST:event_ProceedButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DevicePropertiesFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DevicePropertiesFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DevicePropertiesFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DevicePropertiesFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                //new DevicePropertiesFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelButton;
    private javax.swing.JLabel PFNMSLabel;
    private javax.swing.JLabel PFNMSLabel1;
    private javax.swing.JLabel PFNMSLabel2;
    private javax.swing.JLabel PFNMSLabel3;
    private javax.swing.JLabel PFNMSLabel4;
    private javax.swing.JButton ProceedButton;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTextFieldAlarmEmail;
    private javax.swing.JTextField jTextFieldContDetail;
    private javax.swing.JTextField jTextFieldName;
    private javax.swing.JTextField jTextFieldSysAdmin;
    // End of variables declaration//GEN-END:variables
}
